package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IDrawBookCatalogFragmentModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Kay on 2016-6-3.
 */
public class DrawBookCatalogFragmentModel extends BaseModel implements IDrawBookCatalogFragmentModel, HttpWebServiceCallBack {


    public DrawBookCatalogFragmentModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    /**
     * 获取绘本目录
     *
     * @param agecode 年龄段编码
     * @param typeid
     */
    @Override
    public void doGetDrawBookCatalog(String agecode, String typeid) {
        Map<String, String> params = new HashMap<>();
        if (agecode != null) {
            params.put("agecode", agecode);
        }
        if (typeid != null) {
            params.put("typeid", typeid);
        }
        HttpWebService.getDataFromServer(NetConstant.GETDRAWBOOKCATALOG, params, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null)
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
    }
}
